//
//  YHMyMerchantCell.m
//  YHApp
//
//  Created by -- on 2021/7/7.
//

#import "HAMerchantCell.h"
#import "HAMerchantListMo.h"

@interface HAMerchantCell ()

/***/
@property (nonatomic, strong) UIView *mainV;
/***/
@property (nonatomic, strong) UIImageView *iconImgV;
/***/
@property (nonatomic, strong) UILabel *nameL;
/***/
@property (nonatomic, strong) UILabel *numL;
/***/
@property (nonatomic, strong) UIImageView *RImgV;
/***/
@property (nonatomic, strong) UIView *lineV;
/***/
@property (nonatomic, strong) UILabel *statelabel;

@end

@implementation HAMerchantCell

-(void)setModel:(HAMerchantListMo *)model {
    _model = model;
    
    self.nameL.text = _model.short_name;
    self.numL.text = [NSString stringWithFormat:@"编号:%@",_model.number];
    self.statelabel.text = _model.statelabel;
    [self.iconImgV setImageWithURL:[NSURL URLWithString:_model.avatar] placeholder:nil];
}

-(void)layoutSubviews {
    [super layoutSubviews];
    
    [self.mainV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    
    [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.right.mas_equalTo(-20);
        make.bottom.mas_equalTo(0);
        make.height.mas_offset(0.6);
    }];
    
    [self.iconImgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(20);
        make.centerY.mas_equalTo(0);
        make.width.mas_offset(44);
        make.height.mas_offset(44);
    }];
    
    [self.RImgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_offset(5);
        make.height.mas_offset(10);
        make.centerY.mas_equalTo(0);
        make.right.mas_equalTo(-20);
    }];

    [self.nameL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.iconImgV.mas_right).offset(12);

        make.centerY.mas_equalTo(-12);
    }];
    
    [self.numL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.iconImgV.mas_right).offset(12);

        make.centerY.mas_equalTo(10);
    }];
    
    [self.statelabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.RImgV.mas_left).offset(-5);
        make.centerY.mas_equalTo(0);
    }];

    
}

- (UIView *)mainV
{
    if (!_mainV) {
        _mainV = [UIView ha_createView];
        _mainV.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_mainV];
    }
    return _mainV;
}

- (UIImageView *)iconImgV
{
    if (!_iconImgV) {
        _iconImgV = [UIImageView ha_createImageView];
        [self.mainV addSubview:_iconImgV];
    }
    return _iconImgV;
}

- (UILabel *)nameL
{
    if (!_nameL) {
        _nameL = [UILabel ha_NLabelWithFont:17 textColor:@"#111A34" text:@"" alignment:0];
        [self.mainV addSubview:_nameL];
    }
    return _nameL;
}

- (UILabel *)numL
{
    if (!_numL) {
        _numL = [UILabel ha_NLabelWithFont:12 textColor:@"#858B9C" text:@"" alignment:0];
        [self.mainV addSubview:_numL];
    }
    return _numL;
}

- (UILabel *)statelabel
{
    if (!_statelabel) {
        _statelabel = [UILabel ha_NLabelWithFont:12 textColor:@"#666666" text:@"" alignment:2];
        [self.mainV addSubview:_statelabel];
    }
    return _statelabel;
}

- (UIImageView *)RImgV
{
    if (!_RImgV) {
        _RImgV = [UIImageView ha_createImageView];
        _RImgV.image = [UIImage imageNamed:@"ic_cell_more"];
        [self.mainV addSubview:_RImgV];
    }
    return _RImgV;
}

- (UIView *)lineV
{
    if (!_lineV) {
        _lineV = [UIView ha_createView];
        _lineV.backgroundColor = [UIColor kLineColor];
        [self.mainV addSubview:_lineV];
    }
    return _lineV;
}

@end
